/** @author  huangzucun
  * @version V1.0
  * @date    2024-4-1
*/

#ifndef __OLED_H
#define __OLED_H

#include "stm32f10x.h"
#include "stdlib.h"	

//-----------------OLED IIC端口宏定义----------------  	
//使用哪个版本的OLED引脚，下面宏定义设为 1，不使用的设为 0 即可。
#define OLED_STM32F103C8T6V1_0304    0  //STM32F103C8T6小板 V1.03 V1.04版本
#define OLED_STM32F103C8T6_DB_V1_01  1  //STM32F103C8T6带底板的最小系统 V1.01版本
#define OLED_STM32F103VET6_V1_03     0  //STM32F103VET6 V1.03版本

#if OLED_STM32F103C8T6V1_0304

#define OLED_GPIO				GPIOB
#define OLED_GPIO_RCC		RCC_APB2Periph_GPIOB
#define OLED_SCL				GPIO_Pin_9
#define OLED_SDA				GPIO_Pin_8

#elif OLED_STM32F103C8T6_DB_V1_01

#define OLED_GPIO				GPIOB
#define OLED_GPIO_RCC		RCC_APB2Periph_GPIOB
#define OLED_SCL				GPIO_Pin_9
#define OLED_SDA				GPIO_Pin_8

#elif OLED_STM32F103VET6_V1_03 

#define OLED_GPIO				GPIOD
#define OLED_GPIO_RCC		RCC_APB2Periph_GPIOD
#define OLED_SCL				GPIO_Pin_7
#define OLED_SDA				GPIO_Pin_6

#endif
//-----------------OLED IIC端口宏定义结束----------------  

#define OLED_MODE 0
//#define SIZE 8
#define XLevelL		0x00
#define XLevelH		0x10
#define Max_Column	128
#define Max_Row		64
#define	Brightness	0xFF 
#define X_WIDTH 	128
#define Y_WIDTH 	64	

#define OLED_SCLK_Clr() GPIO_ResetBits(OLED_GPIO,OLED_SCL)//SCL
#define OLED_SCLK_Set() GPIO_SetBits(OLED_GPIO,OLED_SCL)
#define OLED_SDIN_Clr() GPIO_ResetBits(OLED_GPIO,OLED_SDA)//SDA
#define OLED_SDIN_Set() GPIO_SetBits(OLED_GPIO,OLED_SDA)	

#define OLED_CMD  0	//写命令
#define OLED_DATA 1	//写数据

//OLED控制用函数
void OLED_WR_Byte(unsigned dat,unsigned cmd);  
void OLED_Display_On(void);
void OLED_Display_Off(void);	   							   		    
void OLED_Init(void);
void OLED_Clear(void);
void OLED_DrawPoint(u8 x,u8 y,u8 t);
void OLED_Fill(u8 x1,u8 y1,u8 x2,u8 y2,u8 dot);
void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 Char_Size);
void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size);
void OLED_ShowString(u8 x,u8 y, char *p,u8 Char_Size);	 
void OLED_Set_Pos(unsigned char x, unsigned char y);
void OLED_ShowCHinese(u8 x,u8 y,u8 no);
void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]);
void Delay_50ms(unsigned int Del_50ms);
void Delay_1ms(unsigned int Del_1ms);
void fill_picture(unsigned char fill_Data);
void Picture(void);
void IIC_Start(void);
void IIC_Stop(void);
void Write_IIC_Command(unsigned char IIC_Command);
void Write_IIC_Data(unsigned char IIC_Data);
void Write_IIC_Byte(unsigned char IIC_Byte);

extern char OLED_Temp[20];

#endif  
	 



